from enum import IntEnum

class ChiotDevice(object):
    class DeviceWeak(IntEnum):
        WEAK_BIT_MON = 0x40
        WEAK_BIT_TUE = 0x20
        WEAK_BIT_WED = 0x10
        WEAK_BIT_THU = 0x8
        WEAK_BIT_FRI = 0x4
        WEAK_BIT_SAT = 0x2
        WEAK_BIT_SUN = 0x1

    class ServiceParams:
        def __init__(self, serviceId = "", para = "", paraValue = 0):
            self.serviceId = serviceId
            self.para = para
            self.paraValue = paraValue

    class Timer:
        def __init__(self, id = "", enable = False, start = "", end = "", services = [], week = 0):
            self.id = id
            self.enable = enable
            self.start = start
            self.end = end
            self.services = services
            self.week = week

        def Reset(self):
            self.id = ""
            self.enable = False

            self.start = ""
            self.end = ""

            self.services.clear()

            self.week = 0

        def GetWeekString(self):
            weekString = ""
            if (self.week & int(ChiotDevice.DeviceWeak.WEAK_BIT_MON)) != 0:
                weekString = "周一,"
            if (self.week & int(ChiotDevice.DeviceWeak.WEAK_BIT_TUE)) != 0:
                weekString += "周二,"
            if (self.week & int(ChiotDevice.DeviceWeak.WEAK_BIT_WED)) != 0:
                weekString += "周三,"
            if (self.week & int(ChiotDevice.DeviceWeak.WEAK_BIT_THU)) != 0:
                weekString += "周四,"
            if (self.week & int(ChiotDevice.DeviceWeak.WEAK_BIT_FRI)) != 0:
                weekString += "周五,"
            if (self.week & int(ChiotDevice.DeviceWeak.WEAK_BIT_SAT)) != 0:
                weekString += "周六,"
            if (self.week & int(ChiotDevice.DeviceWeak.WEAK_BIT_SUN)) != 0:
                weekString += "周日,"

            return weekString.removesuffix(",")

    class Delay:
        def __init__(self):
            self.id = ""
            self.enable = False
            self.start = 0
            self.end = 0
            self.services = []

        def Reset(self):
            self.id = ""
            self.enable = False

            self.start = 0
            self.end = 0

            self.services.clear()
            
    class OtaProcess:
        def __init__(self):
            self.startTime = ""
            self.totalTime = ""
            self.process = ""
            self.progress = ""
            self.frequency = ""

    class OtaResult:
        def __init__(self):
            self.result = "0"
            self.firmwareVersion = ""
            self.hardwareVersion = ""
            self.upgradePackageUuid = ""